import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPersist from 'pinia-plugin-persistedstate'

import './styles/theme.css'
import App from './App.vue'
import router from './router'

const app = createApp(App)

const pinia = createPinia()
pinia.use(piniaPersist)

app.use(pinia)
app.use(router)

// 初始化用户状态
import { useAuthStore } from './stores/auth'
const authStore = useAuthStore()
// 应用启动时检查用户登录状态
authStore.fetchMe().catch(() => {
  // 静默处理错误，不影响应用启动
})

app.mount('#app')
